/*
 * Plot2d.java
 *
 * Created on December 17, 2007, 9:18 PM
 */

package org.splot;

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.font.FontRenderContext;
import java.awt.font.TextAttribute;
import java.awt.font.TextLayout;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RoundRectangle2D;
import java.text.AttributedString;

/**
 *
 * @author  daniel
 */
public class Plot2d extends javax.swing.JPanel {
    
    private Dimensions dims;
    private PlotLabels labels;
    
    /** Creates new form Plot2d
     * @param dims 
     */
    public Plot2d(Dimensions dims) {
        this.dims = dims;
        initComponents();
    }
 
    @Override
    public void paint(Graphics g) {
        
        // Setup the Graphics Environment
        Graphics2D g2 = (Graphics2D) g;
        //Dimension d = getSize();
        g2.setBackground(getBackground());
        g2.setColor(Color.white);
        g2.fillRect(0, 0, this.dims.getDimension(Dimensions.Dimension.WIDTH), this.dims.getDimension(Dimensions.Dimension.HEIGHT));
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                            RenderingHints.VALUE_ANTIALIAS_ON);
        g2.setRenderingHint(RenderingHints.KEY_RENDERING,
                            RenderingHints.VALUE_RENDER_QUALITY);
        
        
        // Draw the title and axes labels
        FontRenderContext frc = g2.getFontRenderContext();
        Font f = new Font("sansserif",Font.BOLD,32);
        String s = new String("Test Me");
        TextLayout tl = new TextLayout(s, f, frc);
        g2.setColor(Color.black);
        tl.draw(g2, this.dims.getDimension(Dimensions.Dimension.WIDTH)/2-tl.getAdvance()/2, this.dims.getDimension(Dimensions.Dimension.PADDINGTOP)/2+(tl.getAscent()+tl.getDescent())/2);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
    
}
